import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:part_time_job_pro/pages/agreement/logic.dart';
import 'package:part_time_job_pro/common/style/color.dart';
import 'package:part_time_job_pro/common/style/theme.dart';
import 'package:webview_flutter/webview_flutter.dart';

class AgreementPage extends StatelessWidget {
  AgreementPage({Key? key}) : super(key: key);

  late WebViewController webViewController;

  //路由地址
  static const String routeName = "/agreement";
  final logic = Get.find<AgreementLogic>();
  final state = Get.find<AgreementLogic>().state;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<AgreementLogic>(builder: (logic) {
      return Scaffold(
          backgroundColor: AppColor.norWhite01Color,
          appBar: AppBar(
            backgroundColor: AppColor.norWhite01Color,
            leading: InkWell(
                onTap: () {
                  Get.back();
                },
                child: Container(
                  padding: EdgeInsets.all(10.r),
                  child: Image.asset("assets/images/icon/back.png"),
                )),
            elevation: 0,
            title: const Text(
              "用户协议&隐私协议",
              style: AppTheme.appBarStyle,
            ),
          ),
          body: buildWebView());
    });
  }

  Widget buildWebView() {
    String filePath = 'assets/html/agreement.html';
    webViewController = WebViewController()
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..loadFlutterAsset(filePath);
    return WebViewWidget(controller: webViewController);
  }
}
